﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

using Scheduling.Models.Interfaces;
using Scheduling.Models.Helpers;
using Scheduling.Models.Repos.Database.Objects;

namespace Scheduling.Models.Repos.Database
{
    public class DatabaseUserGroupLoader : IUserGroupLoader
    {
        public List<UserGroup> GetUserGroups()
        {
            var db = DBContext.Create();
            var q = from u in db.UserGroups
                    select new { u };
            return LinqHelper.GenericMap<UserGroup>(q, "u");
        }
        public UserGroup GetUserGroup(int ID)
        {
            var db = DBContext.Create();
            var q = from u in db.UserGroups
                    where (u.ID==ID)
                    select new { u };
            return LinqHelper.GenericMap<UserGroup>(q, "u").First();
        }
        
    }
}